import calendar

from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext

from .models import Post

def display_post(request, year, month, day, slug, template='blog/display_post.html'):    
    post = get_object_or_404(Post,
        date_posted__year=int(year),
        date_posted__month=Post.MONTHS.index(month),
        date_posted__day=int(day),
        slug=slug
    )
    
    return render_to_response(template, {
        'post': post,
    }, RequestContext(request))